package com.sskj.hangqing.presenter;

import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.hangqing.http.HttpConfig;
import com.sskj.hangqing.ui.activity.MarketActivity;
import com.sskj.lib.bean.CoinBean;
import com.sskj.lib.http.JsonCallBack;

import java.util.List;


public class MarketActivityPresenter extends BasePresenter<MarketActivity> {



    public void getData(String code) {
        httpService.getProduct(code)
                .execute(new JsonCallBack<HttpData<List<CoinBean>>>() {
                    @Override
                    public void onSuccess(Response<HttpData<List<CoinBean>>> response) {
                        HttpData<List<CoinBean>> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {
                            if (httpData.getData() != null && httpData.getData().size() > 0) {
                                mView.updateUI(httpData.getData().get(0));
                            }
                        }
                    }

                    @Override
                    public void onError(Response<HttpData<List<CoinBean>>> response) {
                        super.onError(response);
                    }
                });
    }
}
